"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMD5Async = exports.getMD5CB = void 0;
const crypto = require("crypto");
const fs = require("fs");
function getMD5CB(filePath, cb) {
    let MD5 = "";
    let stream = fs.createReadStream(filePath);
    let fsHash = crypto.createHash('md5');
    stream.on('error', (e) => {
        console.error(e.message);
        cb(e);
    });
    stream.on('data', function (d) {
        fsHash.update(d);
    });
    stream.on('end', function () {
        MD5 = fsHash.digest('hex');
        cb(undefined, MD5);
    });
}
exports.getMD5CB = getMD5CB;
function getMD5Async(filePath) {
    return new Promise((resolve, reject) => {
        getMD5CB(filePath, (e, value) => {
            if (e)
                reject(e);
            else
                resolve(value);
        });
    });
}
exports.getMD5Async = getMD5Async;
